package com.itzol.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.itzol.config.Result;
import com.itzol.entity.Consume;
import com.itzol.entity.Users;
import com.itzol.mapper.UsersMapper;
import com.itzol.service.ConsumeService;
import com.itzol.service.UsersService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author linxin
 * @since 2021-12-14
 */
@Service
public class UsersServiceImpl extends ServiceImpl<UsersMapper,Users> implements UsersService {

    @Autowired
    private UsersService usersService;
    @Override
    public Result login(Users users) {
        QueryWrapper wrapper = new QueryWrapper();
        wrapper.eq("UserName",users.getUserName());
        wrapper.eq("Password",users.getPassword());
        if (usersService.getOne(wrapper)!=null){
            return Result.succ("登录成功");
        }
        else {
            return Result.erreo("账号或密码错误");
        }
    }
    @Autowired
    private ConsumeService consumeService;
    @Override
    public Result GetConsume(Integer id){
        QueryWrapper<Consume> wrapper = new QueryWrapper<>();
        wrapper.eq("consumer",id);
        List<Consume> list = consumeService.list(wrapper);
        return Result.succ(list);
    }
}
